package com.czmh.etc.onlinepubsys.controller.mingchuang;

import com.alibaba.fastjson.JSON;
import com.czmh.etc.common.core.annotation.ApiVersion;
import com.czmh.etc.onlinepubsys.constants.mingchuang.BusinessType;
import com.czmh.etc.onlinepubsys.json.JsonResult;
import com.czmh.etc.onlinepubsys.json.mingchuang.JSONResult;
import com.czmh.etc.onlinepubsys.json.mingchuang.UnionPayJSONResult;
import com.czmh.etc.onlinepubsys.request.mingchuang.UnionPayAddRequest;
import com.czmh.etc.onlinepubsys.request.mingchuang.UnionPayQueryRequest;
import com.czmh.etc.onlinepubsys.services.UnionPayService;
import com.czmh.etc.onlinepubsys.utils.mingchuang.HttpUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName：JyController
 * @Description：铭创银联对接控制器
 * @Author： Chenzj.
 * @Date：2020/09/21 10:33.
 * @Version：1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/{version}/api/mingchuang/unionpay/")
@Api(tags = "铭创银联对接")
public class UnionPayController {
    @Autowired
    private UnionPayService unionPayService;

    /**
     * 新增会员接口
     *
     * @return
     */
    @ApiVersion(1)
    @PostMapping("/add")
    @ApiOperation(value = "新增会员接口", notes = "新增会员接口")
    public UnionPayJSONResult add(@RequestBody UnionPayAddRequest req) {
        UnionPayJSONResult result;
        log.info("铭创银联对接-新增会员接口:{}", JSON.toJSONString(req));
        result = unionPayService.add(req);
        return result;
    }

    /**
     * 申请开通结算户
     *
     * @return
     */
    @ApiVersion(1)
    @PostMapping("/apply")
    @ApiOperation(value = "申请开通结算户", notes = "申请开通结算户")
    public UnionPayJSONResult apply(@RequestBody UnionPayAddRequest req) {
        UnionPayJSONResult result;
        log.info("铭创银联对接-申请开通结算户接口:{}", JSON.toJSONString(req));
        result = unionPayService.apply(req);
        return result;
    }

    /**
     * 结算户查询
     *
     * @return
     */
    @ApiVersion(1)
    @PostMapping("/query")
    @ApiOperation(value = "结算户查询", notes = "结算户查询")
    public UnionPayJSONResult query(@RequestBody UnionPayQueryRequest req) {
        UnionPayJSONResult result;
        log.info("铭创银联对接-结算户查询接口:{}", JSON.toJSONString(req));
        result = unionPayService.query(req);
        return result;
    }

}
